/* films1.c -- using an array of structures */
#include <stdio.h>
#include <stdlib.h>
#include "list/list.h"

int main(void)
{
	Node h;
	List head = &h;
	Item movie = {0};

	listInit(&head);

    puts("Enter first movie title:");
    while (gets(movie.title) != NULL &&
           movie.title[0] != '\0')
    {
        puts("Enter your rating <0-10>:");
        scanf("%d", &movie.rating);
        while(getchar() != '\n')
            continue;

		head->addItem(&head, movie);
        puts("Enter next movie title (empty line to stop):");
    }


	if(head->isEmpty(&head) == true){
		printf("No data entered. ");
		return 0;
	}

	printf ("Here is the movie list: %d\n", head->count(&head));


	printf("正序遍历:\n");
	head->traverse(&head, printItem);

	printf("逆序遍历:\n");
	head->reverse(&head, printItem);

	head->empty(&head);

	
	printf("Bye!\n");
 
   
    return 0;
}

